Skip to content

fix(fqdn): allow hyphens in last domain label#1548

Merged
zemzale merged 1 commit intogo-playground:masterfrom
alihasan070707:fix/fqdn-hyphen-labels
Mar 27, 2026
Merged

fix(fqdn): allow hyphens in last domain label#1548
zemzale merged 1 commit intogo-playground:masterfrom
alihasan070707:fix/fqdn-hyphen-labels

Conversation

@alihasan070707
Copy link
Copy Markdown
Contributor

Fixes Or Enhances

Summary

The fqdn validator was rejecting valid domain names that contain hyphens in the last label (e.g. test-site-http.test-site), because the TLD character class [a-zA-Z0-9] did not include -.

Change

One character added to the last label's character class in fqdnRegexStringRFC1123:

No other parts of the regex were modified.

Test

Added regression case to TestFQDNValidation:

  • test-site-http.test-site → valid

@go-playground/validator-maintainers

@alihasan070707 alihasan070707 requested a review from a team as a code owner March 20, 2026 02:24
@alihasan070707
Copy link
Copy Markdown
Contributor Author

@zemzale would it be possible for you to review the MR, we have a customer who is blocked due to this issue, would be great if you could review.

Copy link
Copy Markdown
Member

@zemzale zemzale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alihasan070707 does seem correct

@zemzale zemzale merged commit b9258bd into go-playground:master Mar 27, 2026
7 checks passed
@alihasan070707
Copy link
Copy Markdown
Contributor Author

thank you @zemzale, do you know when would these changes will make it to the release?

bfabio pushed a commit to bfabio/validator that referenced this pull request Apr 8, 2026
## Fixes Or Enhances
## Summary

The `fqdn` validator was rejecting valid domain names that contain
hyphens in the last label (e.g. `test-site-http.test-site`), because the
TLD character class `[a-zA-Z0-9]` did not include `-`.

## Change

One character added to the last label's character class in
`fqdnRegexStringRFC1123`:


No other parts of the regex were modified.
 
## Test
 
Added regression case to
[TestFQDNValidation](cci:1://file:///Users/admin/validator/validator_test.go:10628:0-10676:1):
 
- `test-site-http.test-site` → valid

@go-playground/validator-maintainers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants